package com.Lyoto.NetNotify.Constraint;

import com.Lyoto.NetNotify.Utils.NetUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * @author Lyoto
 * @Description 初始化配置的网络配置值
 * @Date 2022-09-19 14:58
 * @Version
 **/
@Slf4j
public class NetConfig {
    
    private static final String defaultIp  = "127.0.0.1";
    private static String ip = defaultIp;

 public static String getIp(){
     return ip;
 }
 public static void setIp(String ip1){
      ip = ip1;
 }

    /**
     *
     */
 public static void setCurrentIp(){
     try {
         ip = NetUtil.getCurrentIp();
         log.info("ip配置加载启动项|成功获取当前ip:{}",ip);
     } catch (IOException e) {
         log.error("ip配置加载|启动时获取当前ip出现错误:",e.fillInStackTrace());
     }
 }
}
